package com.sy.pet.controller.admin;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sy.pet.commom.ResultBean;
import com.sy.pet.dto.PageDTO;
import com.sy.pet.dto.PetTagDTO;
import com.sy.pet.entity.PetTag;
import com.sy.pet.service.PetTagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @Author: liangSY
 * @Date: 2024/9/14
 * @ClassName: PetTagController
 * @Description: PetTagController描述
 */
@RequestMapping("/admin/pet/tag")
@RestController
public class PetTagController {

    @Autowired
    PetTagService petTagService;

    @PostMapping("/page")
    public ResultBean<IPage<PetTag>> getByPage(@RequestBody @Valid PageDTO dto) {
        IPage<PetTag> users = petTagService.getByPage(dto);
        return ResultBean.success(users);
    }


    @DeleteMapping("/{id}")
    private ResultBean<String> removeUser(@PathVariable("id") String id){
        petTagService.remove(id);
        return ResultBean.success();
    }

    @PutMapping
    private ResultBean<String> editTag(@RequestBody @Valid PetTagDTO dto){
        petTagService.edit(dto);
        return ResultBean.success();
    }

    @PostMapping
    private ResultBean<String> addTag(@RequestBody @Valid PetTagDTO dto){
        petTagService.add(dto);
        return ResultBean.success();
    }

}
